<?php
	
	/**
	 * Verifies bootstrapper execution to ensure file
	 * necessities, and disabling direct access
	 */
	defined('ENGINE') or exit;
	
	/**
	 * Parses a string containing BBCode into a more
	 * feasable HTML and IMG string
	 */
	function convert_bbcode($string)
	{
		$bb_codes = array(
			/* Weighted Codes */
			'[b]'		=> '<strong>',
			'[/b]'		=> '</strong>',
			'[strong]'	=> '<strong>',
			'[/strong]'	=> '</strong>',
			/* Italic Styled Codes */
			'[i]'		=> '<em>',
			'[/i]'		=> '</em>',
			'[em]'		=> '<em>',
			'[/em]'		=> '</em>',
			/* Underlined Styled Codes */
			'[u]'		=> '<u>',
			'[/u]'		=> '</u>',
			/* Strikethrough Texts */
			'[s]'		=> '<strike>',
			'[/s]'		=> '</strike>',
			'[strike]'	=> '<strike>',
			'[/strike]'	=> '</strike>',
			/* Quoted Text */
			'[quote]'	=> '<blockquote>',
			'[/quote]'	=> '</blockquote>',
			/* Coded Text */
			'[code]'	=> '<pre>',
			'[/code]'	=> '</pre>',
			/* Images */
			'[img]'		=> '<img src="',
			'[/img]'	=> '" />',
		);
		
		$search		= array_keys($bb_codes);
		$replace	= str_replace($search, $bb_codes, $string);
		
		return($replace);
	}

?>